<template>
  <ElSelect filterable clearable :="$attrs" placeholder="" @change="onChange">
    <ElOption v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
  </ElSelect>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { ElSelect, ElOption } from 'element-plus'
import { getCustomerList } from '../api'

interface Props {
  data: any;
}
const props = withDefaults(defineProps<Props>(), {
  data: () =>({}),
})

const options = ref<Array<{ label: string, value: string }>>([])

const getOptions = () => {
  getCustomerList()
    .then(res => {
      options.value = res
    })
}

const onChange = () => {
  props.data.shopId = ''
  props.data.subAccountItemList = []
}

onMounted(() => {
  getOptions()
})
</script>